package com.hz.pay.center.vo;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;

public class MyMessagePostProcessor implements MessagePostProcessor {

    private Long ttl;

    public MyMessagePostProcessor(Long ttl){
        this.ttl = ttl;
    }


    /**
     * 设置ttl属性
     * @param message
     * @return
     * @throws AmqpException
     */
    @Override
    public Message postProcessMessage(Message message) throws AmqpException {
        message.getMessageProperties().getHeaders().put("expiration", ttl.toString());
        return message;
    }
}
